import { service } from '@/service'

enum Api {
  user = 'users',
  logout = 'logout',
  updatePassword = 'users/update-password',
  me = 'me'
}

export const userList = (params: any) => {
  return service.request({
    url: Api.user,
    method: 'GET',
    params
  })
}

export const userDetail = (user: any) => {
  return service.request({
    url: Api.user + `/${user}`,
    method: 'GET'
  })
}

export const userAdd = (data: any) => {
  return service.request({
    url: Api.user,
    method: 'POST',
    data
  })
}

export const userEdit = (user: number, data: any) => {
  return service.request({
    url: Api.user + `/${user}`,
    method: 'put',
    data
  })
}

export const userDel = (data: any) => {
  return service.request({
    url: Api.user,
    method: 'DELETE',
    data
  })
}

export const userReset = (user: number, data: any) => {
  return service.request({
    url: Api.user + `/${user}/reset-password`,
    method: 'PATCH',
    data
  })
}

export const logoutHttp = () => {
  return service.request({
    url: Api.logout,
    method: 'GET'
  })
}

export const resetPassWord = (user: any, data: any) => {
  return service.request({
    url: `users/${user}/reset-password`,
    method: 'PATCH',
    data
  })
}

export const updatePassword = (data: any) => {
  return service.request({
    url: Api.updatePassword,
    method: 'PATCH',
    data
  })
}

export const getInfoHttp = (params?: any) => {
  return service.request({
    url: Api.me,
    method: 'get',
    params
  })
}
